<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <script>
    const EventCenter = (function (){
      let events = {}
      let listener,remove,trigger;
      
      listener = (name,fn)=>{
        if(!name||!fn)return
        events[name] = events[name] || []
        events[name].push(fn)
      }

      remove = (name) =>{
        if(!name)return;
        delete events[name]
      }

      trigger = (name,...args)=>{
        if(!name||!events[name])return;
        let fns = events[name]
        for(let i=0,len = fns.length;i<len;i++){
          fns[i].call(null, args)
        }
      }

      return {
        listener,remove,trigger
      }
    })()

    EventCenter.listener("test",(args)=>{
      console.log(args)
    })

    EventCenter.trigger("test",111)
    
    EventCenter.remove("test")

    EventCenter.trigger("test",111)

  </script>
</body>
</html>